package fhp.hlhj.giantfold.module

import com.lzy.okgo.model.HttpParams
import fhp.hlhj.giantfold.javaBean.ErroBean
import fhp.hlhj.giantfold.javaBean.SuperMarketListBean
import fhp.hlhj.giantfold.network.UrlApis
import fhp.hlhj.giantfold.utils.LogUtil
import fhp.hlhj.giantfold.utils.MyUtils

/**
 * author: FHP
 * data: on 2017\12\4 0004 17:26
 * E-Mail: 103945089@qq.com
 */
class SuperMarketListModule {
    interface isOkListener{
        fun over(superMarketListBean: SuperMarketListBean)
        fun showLoading()
        fun erro(erro:ErroBean)
        fun overNextPage(superMarketListBean: SuperMarketListBean)
    }

    fun getGoods(params: HttpParams,isOkListener: isOkListener){
        UrlApis.getGoods(params)
                .doOnSubscribe {
                    isOkListener.showLoading()
                }
                .subscribe ({
                    data->
                    isOkListener.over(data)
                },{
                    MyUtils.toast("未知错误")
                })
    }
    fun getNextPageGoods(params: HttpParams,isOkListener: isOkListener,url:String){
        UrlApis.getGoodsNextPage(params,url)
                .doOnSubscribe {

                }
                .subscribe({
                    data->
                    isOkListener.overNextPage(data)
                },{
                    LogUtil.log("错误")
                })
    }

}